﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TripsLogic.controller;
using System.Data;
using TripsLogic.util;

namespace TripsLogic.master.uc
{
    public partial class ucListTrip : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        private void LoadListTrip()
        {
            
            string numberofItem = SysIniController.getSetting("NumberItem_ListTrip","15");
            DataTable dt= TripController.getNewTrips(Convert.ToInt32(numberofItem));
            if (dt != null && dt.Rows.Count > 0)
            {
                string avatarImagePath = SysIniController.getSetting("Avatar_ImagePath", "images/avatar/");
                dt.Columns.Add("Driver", typeof(string));
                dt.Columns.Add("Avatar", typeof(string));
                dt.Columns.Add("CurrentSlot", typeof(int));
             
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //DataTable dtUser = SysUserController.getUserById(dt.Rows[i]["UserId"].ToString());
                    dt.Rows[i]["Driver"] = "Name Sample";
                    dt.Rows[i]["Avatar"] = avatarImagePath + "sample.jpg";
                    dt.Rows[i]["CurrentSlot"] = Convert.ToInt32(DB.getValue("select COUNT (*) AS NumberOfOrders from TRIPJOIN where TripId= " + dt.Rows[i]["Id"] + " and IsApproved = 1 and StatusId !=0;"));
                }
                lstTrips.DataSource = dt;
                lstTrips.DataBind();
            }
        }
    }
}